/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package acoes;

import java.net.URL;
import java.util.List;
import javax.activation.URLDataSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;

/**
 *
 * @author marapao
 */



public class InformacoesAcao {

    public InformacoesAcao() {
    }


    
    
    
    public DadosAcao buscaPorId(String id, List<DadosAcao> inv)
            throws Exception {
        DadosAcao ca = new DadosAcao();

        /*if (id == null) {
        throw new Exception("ERRO - C\363digo da a\347\343o requisitada deve ser informado!");
        }

        URLDataSource source = new URLDataSource(new URL((new StringBuilder()).append("http://www.bovespa.com.br/Cotacoes2000/formCotacoesMobile.asp?codsocemi=").append(id).toString()));
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(source.getInputStream());
        doc.getDocumentElement().normalize();
        NodeList nodeLst = doc.getElementsByTagName("PAPEL");
        if (nodeLst == null) {
        throw new Exception((new StringBuilder()).append("ERRO - Id inv\341lido: ").append(id).toString());
        }
        Node fstNode = nodeLst.item(0);
        String valor = null;
        if (fstNode != null) {
        NamedNodeMap map = fstNode.getAttributes();
        String data[] = map.getNamedItem("DATA").getNodeValue().split("/");


        ca.setDescricao(map.getNamedItem("DESCRICAO").getNodeValue());
        ca.setCodigo(map.getNamedItem("CODIGO").getNodeValue().replace('#', ' ').trim());
        ca.setIbovespa(map.getNamedItem("IBOVESPA").getNodeValue());
        ca.setDelay(map.getNamedItem("DELAY").getNodeValue());
        ca.setData(data[2] + "/" + data[1] + "/" + data[0] + " " + map.getNamedItem("HORA").getNodeValue());
        ca.setOscilacao(map.getNamedItem("OSCILACAO").getNodeValue().replace(',', '.'));
        ca.setUltimoValor(map.getNamedItem("VALOR_ULTIMO").getNodeValue().replace(',', '.'));
        ca.setQuantiNeg(map.getNamedItem("QUANT_NEG").getNodeValue());
        ca.setMercado(map.getNamedItem("MERCADO").getNodeValue());



        } else {
        inv.add(ca);
        }
        if (valor == null) {
        inv.add(ca);
        } else if (valor.equals("0")) {
        inv.add(ca);
        }*/


        return new DadosAcao("", id, "", "", "", "", (Math.random()/150.00)+"", "", "");

    }
}
